package com.itheima.convertstream;

import java.io.*;
import java.nio.charset.Charset;

public class ConvertStreamDemo1 {
    public static void main(String[] args) throws IOException {
        /*利用转换流按照指定字符编码读取（了解）
        因为JDK11：这种方式被淘汰了。替代方案（掌握）
        F:\JavaSE最新版\day29-I0（其他流）\资料\gbkfile.txt*/
/*
        InputStreamReader isr = new InputStreamReader(new FileInputStream("day29-code\\gbkfile.txt"),"GBK");
        int b;
        while ((b=isr.read())!=-1){
            System.out.print((char) b);
        }
        isr.close();*/

        FileReader fr = new FileReader("day29-code\\gbkfile.txt", Charset.forName("gbk"));
        int ch;
        while ((ch=fr.read())!=-1){
            System.out.print((char) ch);
        }
        fr.close();
    }
}
